package com.yan.job;

import com.yan.domainjob.Circle;
import com.yan.domainjob.Graphic;
import com.yan.domainjob.Rectangle;
import com.yan.domainjob.Triangle;

public class Test6 {
    public static void main(String[] args) {
        Graphic[] graphics = new Graphic[3];
        Circle circle = new Circle(4);
        Rectangle rectangle = new Rectangle(3, 4);
        Triangle triangle = new Triangle(3, 4, 5);
        graphics[0] = circle;
        graphics[1] = rectangle;
        graphics[2] = triangle;

        for (int i = 0; i < graphics.length - 1; i++) {
            for (int j = 0; j < graphics.length - 1; j++) {
                if (graphics[j].getArea() > graphics[j + 1].getArea()) {
                    Graphic temp = graphics[j];
                    graphics[j] = graphics[j + 1];
                    graphics[j + 1] = temp;
                }
            }
        }
        for (int i = 0; i < graphics.length; i++) {
            System.out.println(graphics[i].getInfo() + "面积为" + graphics[i].getArea());
        }
    }


}
